//
//  String+Extension.swift
//  SinaWeibo
//
//  Created by yang on 15/11/22.
//  Copyright © 2015年 yang. All rights reserved.
//

import Foundation

extension String{

    func linhref() ->  (link:String?,clineName:String?){
        let pattern = "<a href=\"(.*?)\".*?>(.*?)</a>"
        let regex = try!NSRegularExpression(pattern: pattern, options: [])
        let result = regex.firstMatchInString(self, options: [], range: NSRange(location: 0, length: characters.count))
        let rangeOne = result?.rangeAtIndex(1)
        let rangeTwo = result?.rangeAtIndex(2)
        var subStrOne : String?
        var subStrTwo : String?
        if let one = rangeOne, two = rangeTwo {
            subStrOne = (self as NSString).substringWithRange(one)
            subStrTwo = (self as NSString).substringWithRange(two)
        }
        return (subStrOne,subStrTwo)
    }

}